package com.eaoa.query.pub;

import com.eaoa.base.EABaseQuery;
import com.eaoa.vo.pub.PubRole;

public class PubRoleQuery extends EABaseQuery {

	public PubRoleQuery() {
		super(PubRole.class);
	    addInnerJoin(1, "pubModules", "pubModules", 1);
		addInnerJoin(2, "employees", "employees");
		noCheckOutOfMemory();

	}
	public void setRoleno(Long id) {
		setEQCondition("roleno", id);
	}
	
	public void setNOEQRoleno(Long id) {
		setNOEQCondition("roleno", id);
	}
	
	public void setRolecode(String val) {
		setEQCondition("rolecode", val);
	}
	
	public void setRolename(String val) {
		setLIKECondition("rolename", val);
	}
	
	public void setRoledesc(String val) {
		setLIKECondition("roledesc", val);
	}
	
	public void setSort()
	{
		setASCOrder("rolecode");
	}
	
	public void setEmployeeno(Long empno) {
		setEQCondition("employees.employeeno", empno);
	}
	
	public void fetchSysModules() {
		setLeftJoinFetchs(" inner join fetch this.pubModules ");
	}
	
	public static PubRole loadByRoleno(Long roleno) {
		if (roleno == null)
			return null;
		PubRoleQuery queryer = new PubRoleQuery();
		queryer.setLazy(true);
		queryer.setRoleno(roleno);
		queryer.execute();
		if (queryer.getResults().size() == 0) {
			return null;
		}
		return (PubRole) queryer.getResults().get(0);
	}

}
